import axios from 'axios'
import { baseUrl } from './base'
export default function Ajax(url,data = {}, method='GET'){
	return new Promise(async (resolve,reject)=>{
		url = baseUrl + url
		if(method === "POST"){
			let res =  await axios({url,data,method})
			if(res.status == 200){
				resolve(res.data.data)
			}else{
				reject('数据请求失败',res)
			}
		}else{
			let res =  await axios({url,params:data,method})
			console.log(res)
			if(res.status == 200){
				console.log("执行成功")
				resolve(res.data.data)
			}else{
				reject('数据请求失败',res)
			}
		}
	})
}